/*
 * @Description:
 * @Version: 2.0
 * @Autor: swc
 * @Date: 2024-07-31 17:18:43
 * @LastEditors: swc
 * @LastEditTime: 2024-08-02 11:28:32
 */
/* eslint-disable func-names */
/**
 * 主题配置
 */

let current = null;

const themeList: { [key: string]: any } = {
  default: {
    '--nav-bg-color': '#5a6b92',
    '--nav-hover-bg-color': '#54658a',
    '--nav-font-color': 'rgba(255, 255, 255, 0.9)'
  },
  simpleWhite: {
    '--nav-bg-color': '#fff',
    '--nav-hover-bg-color': '#f1f1f1',
    '--nav-font-color': '#333'
  }
};

const setTheme = function(name: string) {
  if (current !== name) {
    if (themeList[name]) {
      for (const key in themeList[name]) {
        document.documentElement.style.setProperty(key, themeList[name][key]);
      }
      localStorage.setItem('theme', name); // 缓存主题
      current = name;
    }
  }
};

const getTheme = function() {
  return localStorage.getItem('theme') || 'default';
};
const initTheme = function() {
  // setTheme(getTheme());
};

export { getTheme, initTheme, setTheme };
